package com.vincent.javacourse.controller;


import com.vincent.javacourse.entity.Notice;
import com.vincent.javacourse.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author admin
 * @since 2021-12-24
 */
@RestController
@RequestMapping("//notice")
public class NoticeController {
    @Autowired
    private NoticeService noticeService;

    @GetMapping("/list")
    private List<Notice> list() {
        return this.noticeService.list();
    }

    @DeleteMapping("/delete/{id}")
    public boolean delete(@PathVariable("id") Integer id) {
        return this.noticeService.removeById(id);
    }

    @GetMapping("/find/{id}")
    public Notice find(@PathVariable("id") Integer id) {
        return this.noticeService.getById(id);
    }

    @PostMapping("/add")
    public boolean add(@RequestBody Notice notice) {
        return this.noticeService.save(notice);
    }

    @PutMapping("/update")
    public boolean update(@RequestBody Notice notice) {
        return this.noticeService.updateById(notice);
    }
}

